/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.kai.zhouzhi.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Kenny Lin
 */
@Entity
@Table(name = "product", catalog = "nature", schema = "")
@NamedQueries({
    @NamedQuery(name = "Product.findAll", query = "SELECT p FROM Product p"),
    @NamedQuery(name = "Product.findByProductId", query = "SELECT p FROM Product p WHERE p.productId = :productId"),
    @NamedQuery(name = "Product.findByProductName", query = "SELECT p FROM Product p WHERE p.productName = :productName"),
    @NamedQuery(name = "Product.findByProductAuthor", query = "SELECT p FROM Product p WHERE p.productAuthor = :productAuthor"),
    @NamedQuery(name = "Product.findByProductFrom", query = "SELECT p FROM Product p WHERE p.productFrom = :productFrom"),
    @NamedQuery(name = "Product.findByProductDate", query = "SELECT p FROM Product p WHERE p.productDate = :productDate"),
    @NamedQuery(name = "Product.findByProductViewNum", query = "SELECT p FROM Product p WHERE p.productViewNum = :productViewNum"),
    @NamedQuery(name = "Product.findByProductPhoto", query = "SELECT p FROM Product p WHERE p.productPhoto = :productPhoto"),
    @NamedQuery(name = "Product.findByProductDesc", query = "SELECT p FROM Product p WHERE p.productDesc = :productDesc")})
public class Product implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "product_id", nullable = false)
    private Integer productId;
    @Basic(optional = false)
    @Column(name = "product_name", nullable = false, length = 100)
    private String productName;
    @Basic(optional = false)
    @Column(name = "product_author", nullable = false, length = 20)
    private String productAuthor;
    @Column(name = "product_from", length = 50)
    private String productFrom;
    @Basic(optional = false)
    @Column(name = "product_date", nullable = false, length = 20)
    private String productDate;
    @Basic(optional = false)
    @Column(name = "product_view_num", nullable = false)
    private int productViewNum;
    @Basic(optional = false)
    @Column(name = "product_photo", nullable = false, length = 50)
    private String productPhoto;
    @Basic(optional = false)
    @Column(name = "product_desc", nullable = false, length = 1000)
    private String productDesc;
    @JoinColumn(name = "product_cate_id", referencedColumnName = "product_cate_id", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private ProductCate productCateId;

    public Product() {
    }

    public Product(Integer productId) {
        this.productId = productId;
    }

    public Product(Integer productId, String productName, String productAuthor, String productDate, int productViewNum, String productPhoto, String productDesc) {
        this.productId = productId;
        this.productName = productName;
        this.productAuthor = productAuthor;
        this.productDate = productDate;
        this.productViewNum = productViewNum;
        this.productPhoto = productPhoto;
        this.productDesc = productDesc;
    }

    public Integer getProductId() {
        return productId;
    }

    public void setProductId(Integer productId) {
        this.productId = productId;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public String getProductAuthor() {
        return productAuthor;
    }

    public void setProductAuthor(String productAuthor) {
        this.productAuthor = productAuthor;
    }

    public String getProductFrom() {
        return productFrom;
    }

    public void setProductFrom(String productFrom) {
        this.productFrom = productFrom;
    }

    public String getProductDate() {
        return productDate;
    }

    public void setProductDate(String productDate) {
        this.productDate = productDate;
    }

    public int getProductViewNum() {
        return productViewNum;
    }

    public void setProductViewNum(int productViewNum) {
        this.productViewNum = productViewNum;
    }

    public String getProductPhoto() {
        return productPhoto;
    }

    public void setProductPhoto(String productPhoto) {
        this.productPhoto = productPhoto;
    }

    public String getProductDesc() {
        return productDesc;
    }

    public void setProductDesc(String productDesc) {
        this.productDesc = productDesc;
    }

    public ProductCate getProductCateId() {
        return productCateId;
    }

    public void setProductCateId(ProductCate productCateId) {
        this.productCateId = productCateId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (productId != null ? productId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Product)) {
            return false;
        }
        Product other = (Product) object;
        if ((this.productId == null && other.productId != null) || (this.productId != null && !this.productId.equals(other.productId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.kai.zhouzhi.entity.Product[productId=" + productId + "]";
    }

}
